package com.ims.service.impl;

import com.ims.dao.DaoSupport;
import com.ims.entity.system.Course;
import com.ims.service.CourseService;
import com.ims.util.PageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class CourseServiceImpl implements CourseService {
    @Resource(name="daoSupport")
    private DaoSupport dao;

    @Override
    public List<Course> listAllCourse() throws Exception {

        return (List<Course>) dao.findForList("CourseMapper.listAllCourse",null);
    }

    @Override
    public List<Course> listSubCourse(String attribute) throws Exception {
        return (List<Course>) dao.findForList("CourseMapper.listCourseByCAttribute",attribute);
    }

    @Override
    public PageData getCourseByCno(PageData pd) throws Exception {
        return (PageData) dao.findForObject("CourseMapper.getCourseById",pd);
    }

    @Override
    public void deleteCourseByCno(Integer cno) throws  Exception {
        dao.save("CourseMapper.deleteCourseById",cno);
    }

    @Override
    public void saveCourse(Course course) throws Exception {
        dao.save("CourseMapper.insertCourse",course);
    }


}
